Filters highlighted by Ansible :
https://docs.ansible.com/ansible/latest/user_guide/playbooks_filters.html
List of Jinja2 Filters :
https://jinja.palletsprojects.com/en/2.11.x/templates/#builtin-filters
Common used Filters :
- {{ my_var | default("myval") }} : assign default value "myval" to the variable "my_var" if it not defined.
- {{ user_password | password_hash('sha512') }} : transform the variable value to a sha512 password hash . Useful when using "user" module to create/update users with their passwords.
- The following filters change the format of the variable data structure to json or yaml or even to a pretty json or yaml :
{{ some_variable | to_json }}
{{ some_variable | to_yaml }}
{{ some_variable | to_nice_json }}
{{ some_variable | to_nice_yaml }}